//
// Created by root on 6/24/17.
//

#ifndef FUNNY_UTILS_H
#define FUNNY_UTILS_H

#include <stdio.h>

//regex
int match_regex(char* regex, char* text);
char** match_regex_groups(char* regex, int groups, char* text);

//string
char* concatenate(char* str, char* append);
char* get_category(char *line, char categoryChar);

//file
void* read_file(char* inputFile, void* (*process_read)(FILE *in));
void* write_file(char* outputFile, void* (*process_write)(FILE *out));
void* read_write_file(char* inputFile, char* outputFile, void* (*process_read_write)(FILE *in, FILE *out));

void* read_file_with_data(char* inputFile, void* data, void* (*process_read)(FILE *in, void* data));
void* write_file_with_data(char* outputFile, void* data, void* (*process_write)(FILE *out, void* data));
void* read_write_file_with_data(char* inputFile, char* outputFile, void* data, void* (*process_read_write)(FILE *in, FILE *out, void* data));

int repetitions(FILE *stream, int c);
int fpeek(FILE *stream);
char* read_until(FILE *fp, int (*condition)(int c));
char* read_line(FILE *fp);
char** read_lines(FILE *fp);

#endif //FUNNY_UTILS_H
